package com.jkl.controller.person;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jkl.entity.BaseResponseDTO;
import com.jkl.entity.person.BsPerson;
import com.jkl.service.person.inter.BsPersonServiceInterface;

import lombok.extern.slf4j.Slf4j;

/**
 * 
 * <p>
 * 123开放层接口
 * <p>
 * <p>
 * 变更说明：lin.pf 2017年12月28日 123 增加新增、更新、删除方法
 * <p>
 * Date:2018年10月01日
 * 
 * @author lin.pf
 * @version 1.0
 */
@RestController
@RequestMapping("/jky/person")
@Slf4j
public class BsPersonControllerV1 {

	@Autowired
	private HttpServletRequest request;

	@Autowired
	private BsPersonServiceInterface bsPersonServiceInterface;

	@PostMapping("/findPersonByAreaId")
	public BaseResponseDTO findPersonByAreaId(@RequestBody BsPerson params) {
		BaseResponseDTO returnData = new BaseResponseDTO();
		PageInfo<BsPerson> bInfo = bsPersonServiceInterface.findPersonByAreaId(params);
		JSONObject returnJson = new JSONObject();
		returnJson.put("bInfo", bInfo);
		returnData.setReturnData(returnJson);
		return returnData;
	}

	@PostMapping("/updatePersonByParam")
	public boolean updatePersonByParam(@RequestBody BsPerson params) {
		bsPersonServiceInterface.updatePersonByParam(params);
		return true;
	}

	@PostMapping("/addPerson")
	public boolean addPerson(@RequestBody BsPerson person) throws Exception {
		bsPersonServiceInterface.addPerson(person);
		return true;
	}

	@PostMapping("/getPersonByDept")
	public List<BsPerson> getPersonByDept(@RequestBody BsPerson person) throws Exception {
		return bsPersonServiceInterface.getPersonByDept(person);
	}
}